package com.sap.apitest2.deprecated.client;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;

import com.sap.apitest2.deprecated.service.IService;


public class ResultTest extends AbstractTest implements IService {
	 public static void main(String args[]) throws Exception {
	        
		 	testRequestJsonGetLastResultsBySubcase();
		 	//testRequestJsonGetLastResultsByCase();
		 	//testRequestJsonGetAllResultsBySubcase();
		 	//testRequestJsonGetAllResultsByCase();
	        System.out.println("\n"); 
	        System.exit(0);
	    }
    private static void testRequestJsonGetLastResultsBySubcase()throws Exception{
    	System.out.println("\n");
        System.out.println("Sent HTTP GET request to get result info, expect JSON");
        GetMethod get = new GetMethod(getTestHost()+ACTION_LASTRESULTS+"/0/2");
        get.addRequestHeader("Accept" , "application/json");
        HttpClient httpclient = new HttpClient();
       
        try {
            int result = httpclient.executeMethod(get); 
            System.out.println("Response status code: " + result);
            System.out.println("Response body: ");
            System.out.println(get.getResponseBodyAsString());
        } finally {
            get.releaseConnection();             
        }
    }
    private static void testRequestJsonGetLastResultsByCase()throws Exception{
    	System.out.println("\n");
        System.out.println("Sent HTTP GET request to get result info, expect JSON");
        GetMethod get = new GetMethod(getTestHost()+ACTION_LASTRESULTS+"/1/0");
        get.addRequestHeader("Accept" , "application/json");
        HttpClient httpclient = new HttpClient();
       
        try {
            int result = httpclient.executeMethod(get); 
            System.out.println("Response status code: " + result);
            System.out.println("Response body: ");
            System.out.println(get.getResponseBodyAsString());
        } finally {
            get.releaseConnection();             
        }
    }
    
    private static void testRequestJsonGetAllResultsBySubcase()throws Exception{
    	System.out.println("\n");
        System.out.println("Sent HTTP GET request to get result info, expect JSON");
        GetMethod get = new GetMethod(getTestHost()+ACTION_ALLRESULTS+"/1/1");
        get.addRequestHeader("Accept" , "application/json");
        HttpClient httpclient = new HttpClient();
       
        try {
            int result = httpclient.executeMethod(get); 
            System.out.println("Response status code: " + result);
            System.out.println("Response body: ");
            System.out.println(get.getResponseBodyAsString());
        } finally {
            get.releaseConnection();             
        }
    }
    private static void testRequestJsonGetAllResultsByCase()throws Exception{
    	System.out.println("\n");
        System.out.println("Sent HTTP GET request to get result info, expect JSON");
        GetMethod get = new GetMethod(getTestHost()+ACTION_ALLRESULTS+"/1/0");
        get.addRequestHeader("Accept" , "application/json");
        HttpClient httpclient = new HttpClient();
       
        try {
            int result = httpclient.executeMethod(get); 
            System.out.println("Response status code: " + result);
            System.out.println("Response body: ");
            System.out.println(get.getResponseBodyAsString());
        } finally {
            get.releaseConnection();             
        }
    }
}
